package com.elitel.common.businessJdbc.mysql;

import java.sql.PreparedStatement;

import com.elitel.common.businessJdbc.BusinessSelectPreparedStatement;

public class MysqlSelectPreparedStatement extends BusinessSelectPreparedStatement{

    // default mysql syntax
    @Override
    public String getPrecompileSql(){
        // useing mysql Test
        StringBuilder sb = new StringBuilder();
        sb.append("select a.* from ( ")
            .append(sqlTemplate())
            .append(getOrderSection())
            .append(" ) a");
        if(isPageable()){
            sb.append(containPageableSqlSection());
        }

        return sb.toString();
    }

    public String containPageableSqlSection(){
        StringBuilder sb = new StringBuilder();
        sb.append(" LIMIT ")
            .append(getPageNumber() - 1)
            .append(",")
            .append(getPageSize());
        return sb.toString();
    }

}
